//redis在recom3中暂时未使用到
package dbConnector

import (
	"fmt"
)
import (
	"code.google.com/p/gcfg"
	"gopkg.in/redis.v4"
)

type RedisDB struct {
	Client    *redis.Client
	RedisConf RConf
}
type RConf struct {
	Addr        string
	Password    string
	DB          int
	PoolSize    int
	ListKey     string
	AccStateKey string
}

var Redisdb *RedisDB

func Init(confPath string) error {
	Redisdb = new(RedisDB)
	err := gcfg.ReadFileInto(Redisdb, confPath)
	if err != nil {
		return fmt.Errorf("gcfg.ReadFileInto(): %s", err.Error())
	}
	conf := Redisdb.RedisConf
	Redisdb.Client = redis.NewClient(&redis.Options{
		Addr:     conf.Addr,
		Password: conf.Password,
		DB:       conf.DB,
		PoolSize: conf.PoolSize,
	})
	return nil
}
